<?php

use Illuminate\Support\Facades\Route;



// 小程序sessionKey
Route::post('/login/mini/session', 'LoginController@miniSession');

// 小程序手机号登录
Route::post('/login/mini/mobile', 'LoginController@miniMobileLogin');

// 小程序静默登录
Route::post('/login/mini/silent', 'LoginController@miniSilentLogin');

Route::any('/wechat/platform', 'WechatOpenController@callback');

Route::get('/wechat/{appId}/platform', 'WechatOpenController@message');

Route::post('/aliyun/callback', 'AliyunController@aliyunRefreshVideoToken');

Route::post('/aliyun/callback', 'AliyunController@callback');


Route::get('/wechat/platform/oauth', 'WechatOpenController@getAuthUrl');


Route::group(['middleware' => ['auth:apiv2']], function () {


    Route::group(['prefix' => 'search'], function () {

        Route::get('/keyword', 'SearchController@keyword');
        Route::get('/latest', 'SearchController@latest');
        Route::delete('/delete', 'SearchController@delete');
    });




    Route::group(['prefix' => 'my'], function () {

        Route::post('/authorizer', 'MyController@authorizer');
        Route::post('/submission', 'MyController@submission');
        Route::get('/home', 'MyController@home');
        Route::get('/detail', 'MyController@detail');
        Route::get('/message', 'MyController@messages');
        Route::get('/credit', 'MyController@credit');
        Route::post('/favorites', 'MyController@favorites');
        Route::get('/doubts', 'MyController@doubts');
        Route::get('/addresses', 'MyController@addresses');
        Route::get('/prizes', 'MyController@prizes');
        Route::get('/solutions', 'MyController@solutions');
        Route::get('/notes', 'MyController@notes');
        Route::get('/issues', 'MyController@issues');
        Route::get('/roles', 'MyController@roles');
        Route::get('/groups', 'MyController@groups');
        Route::get('/feed', 'MyController@feed');


// 社交账号绑定回调
        Route::get('socialite/{app}/bind/callback', 'MyController@socialiteBindCallback')->name('api.v2.socialite.bind.callback');
    });



});

Route::group(['middleware' => ['auth:apiv2', 'backend.permission']], function () {


    Route::get('/dashboard', 'DashboardController@index');
    Route::post('/dashboard/chart', 'DashboardController@chart');

    Route::group(['prefix' => 'order'], function () {

        Route::post('/', 'OrderController@index');
        Route::get('/{id}/finish', 'OrderController@finishOrder');
        Route::post('/{id}/refund', 'OrderController@submitRefund');
        Route::post('/transfer', 'OrderController@transfer');
        Route::post('/refund', 'OrderController@refundOrders');
        Route::delete('/refund/{id}', 'OrderController@deleteRefundOrder');

        Route::post('/role', 'OrderController@createRoleOrder');


        Route::post('/payment/wechat/mini', 'PaymentController@wechatMiniPay');
        // 跳转到第三方平台支付[如：支付宝web支付]
        Route::get('/pay/redirect', 'PaymentController@payRedirect');
        // 手动打款支付
        Route::get('/pay/handPay', 'PaymentController@handPay');
        // 微信扫码支付
        Route::post('/pay/wechatScan', 'PaymentController@wechatScan');
        // 获取可用支付网关
        Route::get('/payments', 'PaymentController@payments');

    });
    Route::group(['prefix' => 'account'], function () {

        Route::get('/', 'CountController@index');
        Route::post('/store', 'CountController@store');
        Route::get('/{id}', 'CountController@edit');
        Route::put('/{id}', 'CountController@update');
        Route::delete('/{id}', 'CountController@delete');


    });
    Route::group(['prefix' => 'role'], function () {
        Route::post('/', 'RoleController@index');
        Route::post('/members', 'RoleController@members');
        Route::post('/appraise', 'RoleController@appraise');
        Route::post('/store', 'RoleController@store');
        Route::get('/{id}', 'RoleController@edit');
        Route::put('/{id}', 'RoleController@update');
        Route::delete('/{id}', 'RoleController@delete');
        Route::post('/{id}/privilege/sync', 'RoleController@syncPrivilege');
        Route::delete('/{id}/privilege/{privilegeId}/delete', 'RoleController@deletePrivilege');

    });



    Route::group(['prefix' => 'recommend'], function () {
        Route::post('/store', 'RecommendProductController@store');
        Route::delete('/{id}', 'RecommendProductController@delete');


    });


    Route::group(['prefix' => 'privilege'], function () {
        Route::post('/', 'PrivilegeController@index');
        Route::post('/store', 'PrivilegeController@store');
        Route::get('/{id}', 'PrivilegeController@edit');
        Route::put('/{id}', 'PrivilegeController@update');
        Route::delete('/{id}', 'PrivilegeController@delete');
    });

    Route::group(['prefix' => 'solution'], function () {

        Route::post('/{type}/{id}/submit', 'SolutionController@submit');
        Route::get('/{id}', 'SolutionController@edit');
        Route::put('/{id}', 'SolutionController@update');

    });
    Route::group(['prefix' => 'issue'], function () {

        Route::get('/', 'IssueController@index');

    });

    Route::group(['prefix' => 'article'], function () {


        Route::post('/store', 'ArticleController@store');
        Route::get('/add', 'ArticleController@add');
        Route::get('/{id}', 'ArticleController@edit');
        Route::put('/{id}', 'ArticleController@update');
        Route::put('/{id}/title', 'ArticleController@updateTitle');
        Route::put('/{id}/thumb', 'ArticleController@updateThumb');
        Route::put('/{id}/show', 'ArticleController@show');
        Route::delete('/{id}', 'ArticleController@delete');
        Route::delete('/batch/delete', 'ArticleController@batchDelete');
        Route::post('/remove', 'ArticleController@remove');


    });

    //文集管理

//视频管理
    Route::group(['prefix' => 'video'], function () {
        Route::put('/free', 'VideoController@free');
        Route::post('/remove', 'VideoController@remove');
        Route::put('/unfree', 'VideoController@unfree');
        Route::get('/{id}', 'VideoController@edit');
        Route::post('/store', 'VideoController@store');
        Route::post('/upload', 'VideoController@upload');
        Route::put('/{id}/thumb', 'VideoController@updateThumb');
        Route::get('/add', 'VideoController@add');
        Route::post('/batch/store', 'VideoController@batchStore');
        Route::delete('/{id}', 'VideoController@delete');
        Route::put('/{id}/show', 'VideoController@show');
        Route::delete('/batch/delete', 'VideoController@batchDelete');
        Route::put('/{id}', 'VideoController@update');
        Route::put('/{id}/title', 'VideoController@updateTitle');
        Route::get('/{id}/snapshot', 'VideoController@getSnapshot');
        Route::put('/{id}/thumb', 'VideoController@updateThumb');
        Route::get('/videoFree/{id}', 'VideoController@freeDetail');
        Route::get('/{id}/play/free', 'VideoController@playFree');
        Route::get('/{id}/play/info', 'VideoController@playInfo');
        Route::get('/{id}/notes', 'VideoController@notes');
        Route::get('/{id}/issues', 'VideoController@issues');
        Route::post('/{id}/record', 'VideoController@recordVideo');
        Route::post('/maker/store', 'VideoController@batchStoreMaker');
        Route::put('/{id}/mappings', 'VideoController@storeMappings');
        Route::get('/{id}/question', 'VideoController@questions');
        Route::delete('/{id}/question', 'VideoController@deleteQuestion');
        Route::post('/{id}/question', 'VideoController@storeQuestion');
        Route::get('/question/latest', 'VideoController@getBindVideo');

    });





    Route::group(['prefix' => 'file'], function () {

        Route::get('/list', 'FileController@list');
        Route::get('/{id}/detail', 'FileController@detail');
        Route::post('/upload', 'FileController@upload');
        Route::post('/{id}/replace', 'FileController@replace');
        Route::put('/{id}/title', 'FileController@updateTitle');
        Route::post('/{type}/{id}/store', 'FileController@storeResourceFiles');
        Route::delete('/{type}/{id}/delete', 'FileController@deleteResourceFiles');
        Route::delete('/{id}', 'FileController@delete');
        Route::get('/{id}/download', 'FileController@download');
    });




    // 管理员
    Route::group(['prefix' => 'administrator'], function () {
        Route::get('/', 'AdministratorController@index');
        Route::put('/password', 'AdministratorController@editPasswordHandle');
        Route::get('/add', 'AdministratorController@add');
        Route::post('/', 'AdministratorController@store');
        Route::get('/{id}', 'AdministratorController@edit');
        Route::put('/{id}', 'AdministratorController@update');
        Route::delete('/{id}', 'AdministratorController@delete');
    });

    // 权限
    Route::group(['prefix' => 'administrator_permission'], function () {
        Route::get('/', 'AdministratorPermissionController@index');
    });

    // 角色
    Route::group(['prefix' => 'administrator_role'], function () {
        Route::post('/', 'AdministratorRoleController@index');
        Route::get('/add', 'AdministratorRoleController@add');
        Route::post('/store', 'AdministratorRoleController@store');
        Route::get('/{id}', 'AdministratorRoleController@edit');
        Route::put('/{id}', 'AdministratorRoleController@update');
        Route::delete('/{id}', 'AdministratorRoleController@destroy');
    });
    Route::group(['prefix' => 'promoCode'], function () {
        // 优惠码检测
        Route::post('/', 'PromoCodeController@index');
        Route::get('/{code}/check', 'PromoCodeController@checkCode');
        Route::post('/store', 'PromoCodeController@store');
        Route::put('/{id}/update', 'PromoCodeController@update');
        Route::get('/{id}/edit', 'PromoCodeController@edit');
        Route::delete('/{id}/delete', 'PromoCodeController@delete');
        Route::delete('/destroy', 'PromoCodeController@destroy');
        Route::get('/promoCode/{code}', 'PromoCodeController@detail');

    });
    Route::group(['prefix' => 'redeemCode'], function () {
        // 优惠码检测
        Route::post('/', 'RedeemCodeController@index');
        Route::post('/store', 'RedeemCodeController@store');
        Route::delete('/{id}/delete', 'RedeemCodeController@delete');
        Route::get('/{id}/edit', 'RedeemCodeController@edit');
        Route::put('/{id}/update', 'RedeemCodeController@update');
        Route::get('/{id}/claim', 'RedeemCodeController@claim');
        Route::post('/{type}/{id}/redeem', 'RedeemCodeController@redeem');
        Route::get('/{id}/detail', 'RedeemCodeController@detail');
        Route::post('/{id}/product/store', 'RedeemCodeController@productStore');
        Route::delete('/{id}/product/delete', 'RedeemCodeController@productDelete');

    });



    Route::group(['prefix' => 'image'], function () {

        Route::post('/', 'ImageController@index');
        Route::post('/store', 'ImageController@store');
        Route::put('/{id}', 'ImageController@update');
        Route::delete('/{id}', 'ImageController@delete');
    });
    Route::group(['prefix' => 'media'], function () {

        Route::post('/image/upload', 'MediaImageController@upload');
        Route::post('/image', 'MediaImageController@index');
        Route::delete('/image/{id}', 'MediaImageController@delete');
        Route::delete('/image/batch', 'MediaImageController@batchDelete');
        Route::post('/video', 'MediaVideoController@index');

    });

    Route::group(['prefix' => 'tag'], function () {
        Route::post('/', 'TagController@index');
        Route::post('/{type}/{id}/sync', 'TagController@sync');

        Route::get('/{id}/detail', 'TagController@detail');
        Route::get('/category', 'TagController@category');
        Route::post('/store', 'TagController@store');
        Route::put('/{id}', 'TagController@update');
        Route::delete('/{id}', 'TagController@delete');
        Route::delete('/all', 'TagController@all');
        Route::get('/resources', 'TagController@resources');
        Route::get('/category/tree', 'TagCategoryController@tree');
        Route::post('/category/store', 'TagCategoryController@store');
        Route::get('/category/{id}', 'TagCategoryController@edit');
        Route::put('/category/{id}', 'TagCategoryController@update');
        Route::put('/category/{id}/title', 'TagCategoryController@updateTitle');
        Route::delete('/category/{id}', 'TagCategoryController@delete');

    });

    Route::group(['prefix' => 'aliyun'], function () {
        Route::post('/refresh', 'AliyunController@aliyunRefreshVideoToken');
        Route::post('/video/token/create', 'AliyunController@aliyunCreateVideoToken');
        Route::post('/refresh', 'AliyunController@aliyunRefreshVideoToken');
        Route::post('/image/token/create', 'AliyunController@aliyunCreateImageToken');
        Route::post('/image/token/refresh', 'AliyunRecordController@aliyunRefreshImageToken');
        Route::post('/record/refresh', 'AliyunRecordController@aliyunRefreshVideoToken');
        Route::get('/getInfo', 'AliyunController@getVideoInfo');
        Route::post('/videoPlayInfo', 'AliyunController@videoPlayInfo');
        Route::post('/openPlayInfo', 'AliyunController@openPlayInfo');
        Route::get('/clip', 'CloudClipController@getCloudClip');
        Route::get('/clip/list', 'CloudClipController@getCloudClipList');
        Route::post('/clip/video/create', 'CloudClipController@createCloudClipVideo');
        Route::get('/video/play/info', 'AliyunController@getPlayInfo');
        Route::get('/video/list', 'AliyunController@getVideoList');
        Route::get('/image/list', 'AliyunController@getImageList');
    });


    Route::group(['prefix' => 'member'], function () {

        Route::post('/', 'MemberController@index');
        Route::put('/appraise/bind', 'MemberController@bindAppraise');
        Route::put('/{type}/{id}/appraise/generate', 'MemberController@generateAppraise');
        Route::post('/teachers', 'MemberController@teachers');
        Route::put('/work/sync', 'MemberController@syncWorkMember');
        Route::get('/recommends', 'MemberController@recommends');
        Route::get('/create', 'MemberController@create');
        Route::get('/{id}', 'MemberController@edit');
        Route::post('/store', 'MemberController@store');
        Route::put('/{id}', 'MemberController@update');
        Route::put('/field/multi', 'MemberController@updateFieldMulti');
        Route::put('/{id}/tags', 'MemberController@tagUpdate');
        Route::get('/{id}/remark', 'MemberController@remark');
        Route::put('/{id}/remark', 'MemberController@updateRemark');
        Route::get('/{id}/detail', 'MemberController@detail');
        Route::post('/employees', 'MemberController@employees');
        Route::get('/{id}/employee', 'MemberController@employee');
        Route::get('/{id}/employee/chart', 'MemberController@employeeChart');
        Route::post('/subscribe/import', 'MemberController@importSubscribes');
        Route::post('/{type}/{id}', 'MemberController@subscribes');
        Route::post('/subscribe/store', 'MemberController@createSubscribe');
        Route::post('/subscribe/mobile', 'MemberController@createSubscribeByMobile');
        Route::delete('/subscribe', 'MemberController@deleteSubscribe');
        Route::get('/{id}/role', 'MemberController@userRoles');
        Route::get('/{id}/userHistory', 'MemberController@userHistory');
        Route::get('/{id}/order', 'MemberController@userOrders');
        Route::get('/{id}/invite', 'MemberController@userInvite');
        Route::get('/{id}/credit', 'MemberController@credit1Records');
        Route::post('/credit1/change', 'MemberController@credit1Change');
        Route::post('/{id}/message', 'MemberController@sendMessage');
        Route::post('/message/multi', 'MemberController@sendMessageMulti');

        // 用户标签管理

    });


    Route::group(['prefix' => 'comment'], function () {
        Route::post('', 'CommentController@index');
        Route::get('/{id}/answer', 'CommentController@answerComments');
        Route::get('/{type}/{id}', 'CommentController@comments');
        Route::delete('/{id}/delete', 'CommentController@delete');
        Route::post('/{type}/{id}/submit', 'CommentController@submitComment');


    });
    Route::group(['prefix' => 'coupon'], function () {
        Route::post('/', 'CouponController@index');
        Route::post('/store', 'CouponController@store');
        Route::put('/{id}/update', 'CouponController@update');
        Route::get('/{id}/edit', 'CouponController@edit');
        Route::delete('/{id}/delete', 'CouponController@delete');
        Route::delete('/destroy', 'CouponController@destroy');
        Route::post('/{id}/claim', 'CouponController@claim');
        Route::get('/{code}/check', 'CouponController@checkCode');


    });
    Route::group(['prefix' => 'product'], function () {

        Route::post('', 'ProductController@index');
        Route::post('/store', 'ProductController@store');
        Route::put('/{id}', 'ProductController@update');
        Route::get('/{id}', 'ProductController@edit');
        Route::delete('/{id}', 'ProductController@delete');
        Route::delete('/batch/delete', 'ProductController@batchDelete');
    });
    Route::group(['prefix' => 'conquer'], function () {

        Route::get('/', 'ConquerController@index');
        Route::post('/store', 'ConquerController@store');
        Route::put('/{id}', 'ConquerController@update');
        Route::get('/{id}', 'ConquerController@edit');
        Route::delete('/{id}', 'ConquerController@delete');
        Route::delete('/batch/delete', 'ConquerController@batchDelete');

    });

    Route::group(['prefix' => 'slider'], function () {
        Route::get('/', 'SliderController@index');
        Route::post('/store', 'SliderController@store');
        Route::get('/{id}', 'SliderController@edit');
        Route::put('/{id}', 'SliderController@update');
        Route::delete('/{id}', 'SliderController@destroy');
    });

    Route::group(['prefix' => 'yingshi'], function () {
        Route::get('/device/status', 'YingShiController@status');

    });







});






